<?php
/*
	Copyright 2006, 2007, 2008, 2009, 2010 Bastiaan Grutters
    
    This file is part of Ages of Strife website.

    Ages of Strife website is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Ages of Strife website is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Ages of Strife website.  If not, see <http://www.gnu.org/licenses/>.
 */
include( "../global/initialize.php");

aos_header( 'Buidling list' );

$query = "SELECT * " .
		"FROM buildings " .
		"ORDER BY food_income DESC, " .
			"coal_income DESC, " .
			"iron_income DESC, " .
			"housing DESC, " .
			"space DESC, " .
			"name";
$result = mysql_query( $query ) or die( "Query failed : " . mysql_error() );
$num= mysql_numrows( $result );
?>
					<table>
						<tr><th colspan="10">
							<?php transprint( 'Building list' ); ?>
						</th></tr>
						<tr>
							<td><?php transprint( 'Name' ); ?></td>
							<td align="right"><?php transprint( 'Gold cost' ); ?></td>
							<td align="right"><?php transprint( 'Build time' ); ?></td>
							<td align="right"><?php transprint( 'Food income' ); ?></td>
							<td align="right"><?php transprint( 'Coal income' ); ?></td>
							<td align="right"><?php transprint( 'Iron income' ); ?></td>
							<td align="right"><?php transprint( 'Space' ); ?></td>
							<td align="right"><?php transprint( 'Construction Jobs' ); ?></td>
							<td align="right"><?php transprint( 'Jobs' ); ?></td>
							<td align="right"><?php transprint( 'Houses' ); ?></td>
						</tr>
<?php
$i = 0;
while ( $i < $num ) {
?>
						<tr<?php print( $i % 2 == 0 ? ' class="even"' : '' ); ?>>
							<td>
								<a href="../villages/building.php?id=<?php print( mysql_result( $result, $i, "building_id" ) ); ?>">
									<?php transprint( mysql_result( $result, $i, "name" ) ); ?>
								</a>
							</td>
							<td align="right"><strong class="gold"><?php print( number_format( mysql_result( $result, $i, "gold_cost" ) ) ); ?></strong></td>
							<td align="right"><?php print( number_format( mysql_result( $result, $i, "time_cost" ) ) ); ?></td>
							<td align="right"><strong class="food"><?php print( number_format( mysql_result( $result, $i, "food_income" ) ) ); ?></strong></td>
							<td align="right"><strong class="coal"><?php print( number_format( mysql_result( $result, $i, "coal_income" ) ) ); ?></strong></td>
							<td align="right"><strong class="iron"><?php print( number_format( mysql_result( $result, $i, "iron_income" ) ) ); ?></strong></td>
							<td align="right"><strong class="space-used"><?php print( number_format( mysql_result( $result, $i, "space" ) ) ); ?></strong></td>
							<td align="right"><strong class="jobs"><?php print( number_format( mysql_result( $result, $i, "construction_jobs" ) ) ); ?></strong></td>
							<td align="right"><strong class="jobs"><?php print( number_format( mysql_result( $result, $i, "jobs" ) ) ); ?></strong></td>
							<td align="right"><strong class="houses"><?php print( number_format( mysql_result( $result, $i, "housing" ) ) ); ?></strong></td>
						</tr>
<?php
    $i ++;
}
?>
				</table>
<?php
aos_footer();
?>
